import router from './router'
import './assets/css/global.css'
import { createApp } from 'vue'
// import { ElButton, ElForm, ElInput, ElFormItem, ElMessage, ElContainer, ElHeader, ElAside, ElMain, ElMenu, ElSubmenu, ElMenuItem, ElMenuItemGroup, ElBreadcrumb, ElBreadcrumbItem, ElCard, ElRow, ElCol, ElTable, ElTableColumn, ElSwitch, ElTooltip, ElPagination } from 'element-plus'
import ElementPlus from 'element-plus'
import 'element-plus/lib/theme-chalk/index.css'
import App from './App.vue'
import axios from 'axios'

// 分页中文化
import locale from '../node_modules/element-plus/lib/locale/lang/zh-cn'

const app = createApp(App)
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
app.use(ElementPlus, { locale })
app.use(ElementPlus.ElButton)
app.use(ElementPlus.ElForm)
app.use(ElementPlus.ElFormItem)
app.use(ElementPlus.ElInput)
app.use(ElementPlus.ElMessage)
app.use(ElementPlus.ElContainer)
app.use(ElementPlus.ElHeader)
app.use(ElementPlus.ElAside)
app.use(ElementPlus.ElMain)
app.use(ElementPlus.ElMenu)
app.use(ElementPlus.ElSubmenu)
app.use(ElementPlus.ElMenuItem)
app.use(ElementPlus.ElMenuItemGroup)
app.use(ElementPlus.ElBreadcrumb)
app.use(ElementPlus.ElBreadcrumbItem)
app.use(ElementPlus.ElCard)
app.use(ElementPlus.ElRow)
app.use(ElementPlus.ElCol)
app.use(ElementPlus.ElTable)
app.use(ElementPlus.ElTableColumn)
app.use(ElementPlus.ElSwitch)
app.use(ElementPlus.ElTooltip)
app.use(ElementPlus.ElPagination)

axios.interceptors.request.use(config => {
  const tokenStr = window.sessionStorage.getItem('token')
  if (tokenStr) config.headers.Authorization = tokenStr
  return config
})

app.config.globalProperties.$http = axios
app.use(router).mount('#app')
